﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加用户</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../Js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../Js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
     <style type="text/css">
        .edittable td.editcellmessage,.edittable td.editcellverify,.edittable td.editcell{ padding:5px;line-height:25px;}
        .edittable td.editcellmessage{ padding-left:20px;} 
        body { font-size:12px; background:white;}
         
    </style>
    <script type="text/javascript">
        var pWind = null;
        $(function () {
            pWind = parent.window.parent.window.getWindow();
            var initArea = 0;
            var initRole = 0;
            if (pWind) {
                initArea = parseInt($("#Aid", pWind.document).val());
                initRole = parseInt($("#Rid", pWind.document).val());


                $.getJSON('../WebServer/EmpManage.ashx?Action=GetAreRoleID', { "aid": initArea, "rid": initRole }, function (data) {
                    if (parseInt(data.are_role_id) == -1) {
                        showErrorTip("获取区域职务信息出错.");
                        pWind.loadGrid();
                    }
                    else {
                        $("#areroleid").val(data.are_role_id);
                    }
                });
            }
            $("#form1").ligerForm();
            $("#Sex").ligerComboBox({ width: 140, slide: false });
            $("#txtDepartment").ligerComboBox({ width: 140, slide: false, data: null });
            //            $("#txtArea").ligerComboBox({
            //                width: 140,
            //                selectBoxWidth: 200,
            //                selectBoxHeight: 200, valueField: 'id', treeLeafOnly: false, slide: false, initValue: initArea,
            //                tree: { url: '../WebServer/MainAdmin.ashx?Action=AreaTree', checkbox: false },
            //                onSelected: function (newvalue) {
            //                    $("#txtDepartment").ligerGetComboBoxManager().selectValue(0);
            //                    if (newvalue > 0) {
            //                        $.getJSON('../WebServer/UserManage.ashx?Action=Department', { areaid: newvalue, Rnd: Math.random() }, function (data) {
            //                            $("#txtDepartment").ligerGetComboBoxManager().setData(data);
            //                            $("#txtDepartment").ligerGetComboBoxManager().selectValue(initRole);

            //                        });
            //                    }

            //                }
            //            });

            $("#btnCancel").click(function () { closeRefresh(false, ""); });
            $("#btnSave").click(function () {
                Save();
            });
        });

        function chk() {
            var err = "";
            if ($.trim($("#txtUser").val()) == "") {
                err = "用户名不能为空!";
                showErrorTip(err);

                return false;
            }
            err = "";
            if ($.trim($("#txtTel").val()) == "")
                err = "请输入手机号码!";

            else if (!chkMoblie($("#txtTel").val())) {
                err = "手机号码输入不正确"
            }
            if (err != "") {
                showErrorTip(err);
                return false;
            }
            if ($("#txtCode").val() == "") {
                err = "工号不能为空!";
                showErrorTip(err);
                return false;
            }
            if ($.trim($("#txtBuM").val()) == "") {
                err = "工作部门不能为空!";
                showErrorTip(err);
                return false;
            }
//            if ($.trim($("#txtArea").val()) == "") {
//                err = "请选择区域!";
//                showErrorTip(err);
//                return false;
//            }

//            if ($.trim($("#txtDepartment").val()) == "") {
//                err = "请选择职务!";
//                showErrorTip(err);
//                return false;
//            }
            if ($.trim($("#txtPwd").val()) == "") {
                err = "请输入密码!";
                showErrorTip(err);
                return false;
            }
//            if ($("#txtPwd").val() != $("#txtPwdR").val()) {
//                err = "密码不一致!";
//                showErrorTip(err);
//                return false;
//            }
            return true;
        }
        function Save() {
            if (chk()) {
                 var userid=$("#hdUserid").val();
                var user = $("#txtUser").val();
                var sex = $("#Sex").val();
                var tel = $("#txtTel").val();
                var code = $("#txtCode").val();
                var bm = $("#txtBuM").val();
                var email = tel + "@139.com";
                //var are = $("#txtArea").val();
                //var areid = $("#areid").val();
                var areroleid = $("#areroleid").val();
//                var zw = $("#txtDepartment").val();
//                var zwid = $("#txtDepartment_val").val();
                var pwd = $("#txtPwd").val();
                var pars = { userid: userid, user: user, sex: sex, tel: tel, code: code, bm: bm, email: email, areroleid: areroleid, pwd: pwd };
                $("#form1").mask("数据处理中，请稍候......");

                $.getJSON('../WebServer/EmpManage.ashx?Action=AddItemUser', pars, function (data) {
                    $("#form1").unmask();
                    if (data.IsSuccess > 0) {
                        showAlertOk("保存成功");
                        $("#hdUserid").val(data.IsSuccess);
                        if (pWind) pWind.loadGrid();
                    } else {
                        if (data.IsSuccess == -99) {
                            showErrorTip("该手机号已经注册.");
                        } else
                            showErrorTip(data.Msg);
                    }
                    closeRefresh();
                });
            }
        }
    </script>
</head>
<body>
<form id="form1"  action="">
<table cellpadding="0" border="0" cellspacing="0" class="edittable">
            <tr>
                <td  class="editcellmessage">用户名:</td>
                <td  class="editcellmessage"><input id="txtUser" name="txtUser" type="text"  ltype="text" /></td>
            </tr>
            <tr>
                <td  class="editcellmessage">性别:</td>
                <td  class="editcellmessage">
                <select name="Sex" id="Sex" >
                <option value="1">男</option>
                <option value="0">女</option>
                </select>
                </td>
            </tr>
            <tr>
                <td  class="editcellmessage">电话:</td>
                <td  class="editcellmessage"><input id="txtTel" name="txtTel" type="text" ltype="text" maxlength="11" /></td>
            </tr>
            <tr>
                <td  class="editcellmessage">工号:</td>
                <td  class="editcellmessage"><input id="txtCode" name="txtCode" type="text" ltype="text" /></td>
            </tr>
            <tr>
                <td  class="editcellmessage">工作部门:</td>
                <td  class="editcellmessage"><input id="txtBuM" name="txtBuM" type="text" ltype="text" /></td>
            </tr>
          
<!--            <tr>
                <td  class="editcellmessage">区域:</td>
                <td  class="editcellmessage">
                <input id="txtArea" name="txtArea" type="text"  />
                </td>
            </tr>
            <tr>
                <td  class="editcellmessage">职务:</td>
                <td  class="editcellmessage">
                <input id="txtDepartment" name="txtDepartment" type="text"  />
                </td>
            </tr>-->
            <tr>
                <td  class="editcellmessage">密码:</td>
                <td  class="editcellmessage"><input id="txtPwd" name="txtPwd" type="text" value="000000" /></td>
            </tr>
<!--            <tr>
                <td  class="editcellmessage">重复密码:</td>
                <td  class="editcellmessage"><input id="txtPwdR" name="txtPwdR" type="password"  ltype="text"/></td>
            </tr>-->

          
            </table>
             <div class="buttonpanel">
             <div style="float:right;margin-right:10px;">
                 <a id="btnSave" class="button" href="javascript:void(0);"><span>保存</span></a>
                 <a id="btnCancel" class="button" href="javascript:void(0);"><span>关闭</span></a>
              </div>
          </div>
          <input type="hidden" id="hdUserid" value="0" />
          <input type="hidden" id="areroleid" value="-1" />
</form>
</body>
</html>
